/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package org.murillo.chufa.datastructures;
/**
 *
 * @author Administrador
 */
public abstract class BoundedBag<K> {
    
    protected int maxsize;

    protected BoundedBag(int maxsize){
        this.maxsize = maxsize;
    }
    
    public int getMaxsize() {
        return maxsize;
    }

    public void setMaxsize(int maxsize) {
        this.maxsize = maxsize;
    }
    
    public abstract void remove(K k);
    public abstract void add(K k);
    public abstract boolean contains(K k);

    public abstract void clear();
    
    protected static class Counter {

      public int count = 0;

      public Counter() {
      }

      public int add() {
         count++;
         return count;
      }

      public int remove() {
         if (count > 0) {
            count--;
         }
         return count;
      }
   }
    
}
